package com.ming.designPatterns.strategyMode;

/**
 * @Auther: tangC
 * @Date: 2020/7/14 17:00
 * @Description:
 */
public class CashContext {
    private CashSuper cs;

    public CashContext(String rates) {
        switch (rates) {
            case "正常收费":
                cs = new CashNormal();
                break;
            case "满1000减100":
                cs = new CashReturn("1000", "100");
                break;
            case "打8折":
                cs = new CashRebate("0.8");
                break;
            default:
                break;
        }
    }

    //根据收费策略的不同，获得计算结果
    public double getResult(double money) {
        return cs.acceptCash(money);
    }
}
